<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        敏感词
    </div>
    <div class = "word">
        ,,bad,,id,,;akljidd;ei,,sjdknbadword,,
    </div>
</body>
<script>
    var badwords = ["bad","badword"];

    var wordDom = document.querySelector('.word');
    var text = wordDom.innerText;

    for(var i=0;i<badwords.length;i++){
        while(text.indexOf(badwords[i])!=-1){
            text = text.replace(badwords[i],'***');
            wordDom.innerText = text;
        }
    }
</script>

</html>